/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/11
\**********************/
#include "LuaLabel.h"

#define CObjPtr ((CLabelUI*)m_cobj)

namespace DuiLib {

void LuaLabel::SetTextStyle(UINT uStyle)
{
    CObjPtr->SetTextStyle(uStyle);
}

UINT LuaLabel::GetTextStyle()
{
    return CObjPtr->GetTextStyle();
}

void LuaLabel::SetTextColor(DWORD dwTextColor)
{
    CObjPtr->SetTextColor(dwTextColor);
}

DWORD LuaLabel::GetTextColor()
{
    return CObjPtr->GetTextColor();
}

void LuaLabel::SetDisabledTextColor(DWORD dwTextColor)
{
    CObjPtr->SetDisabledTextColor(dwTextColor);
}

DWORD LuaLabel::GetDisabledTextColor()
{
    return CObjPtr->GetDisabledTextColor();
}

void LuaLabel::SetFont(int index)
{
    CObjPtr->SetFont(index);
}

int LuaLabel::GetFont()
{
    return CObjPtr->GetFont();
}

int LuaLabel::GetTextPadding(LuaState *L)
{
    RECT rc = CObjPtr->GetTextPadding();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaLabel::SetTextPadding(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetTextPadding(rc);
    return 0;
}

bool LuaLabel::IsShowHtml()
{
    return CObjPtr->IsShowHtml();
}

void LuaLabel::SetShowHtml(bool bShowHtml)
{
    CObjPtr->SetShowHtml(bShowHtml);
}

int LuaLabel::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

bool LuaLabel::GetAutoCalcWidth()
{
    return CObjPtr->GetAutoCalcWidth();
}

void LuaLabel::SetAutoCalcWidth(bool bAutoCalcWidth)
{
    CObjPtr->SetAutoCalcWidth(bAutoCalcWidth);
}

int LuaLabel::SetText(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetText(str.c_str());
    return 0;
}

SDLUA_BEGIN_REGISTER(LuaLabel, Label, Control)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetTextStyle, SetTextStyle)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, GetTextStyle, GetTextStyle)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetTextColor, SetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, GetTextColor, GetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetDisabledTextColor, SetDisabledTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, GetDisabledTextColor, GetDisabledTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetFont, SetFont)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, GetFont, GetFont)

    SDLUA_REGISTER_FUN_LUA(LuaLabel, GetTextPadding, GetTextPadding)
    SDLUA_REGISTER_FUN_LUA(LuaLabel, SetTextPadding, SetTextPadding)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, IsShowHtml, IsShowHtml)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetShowHtml, SetShowHtml)
    SDLUA_REGISTER_FUN_LUA(LuaLabel, EstimateSize, EstimateSize)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, GetAutoCalcWidth, GetAutoCalcWidth)
    SDLUA_REGISTER_FUN_CPP(LuaLabel, SetAutoCalcWidth, SetAutoCalcWidth)
    SDLUA_REGISTER_FUN_LUA(LuaLabel, SetText, SetText)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaLabel, Label)
SDLUA_END_UNREGISTER(Label)

}

#undef CObjPtr